<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>易莲生梦-刷题帮-桌面版</title>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            line-height: 1.6;
            margin: 0;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            max-width: 1000px;
            margin: 0 auto;
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        h1 {
            text-align: center;
            color: #333;
        }
        .nav {
            display: flex;
            justify-content: space-around;
            margin-bottom: 20px;
            padding: 10px;
            background-color: #eee;
            border-radius: 5px;
        }
        .nav a {
            text-decoration: none;
            color: #333;
            padding: 5px 10px;
            border-radius: 3px;
        }
        .nav a:hover {
            background-color: #ddd;
        }
        .nav a.active {
            background-color: #4CAF50;
            color: white;
        }
        .section {
            display: none;
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
            margin-bottom: 20px;
        }
        .section.active {
            display: block;
        }
        button {
            background-color: #4CAF50;
            color: white;
            border: none;
            padding: 8px 16px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 14px;
            margin: 4px 2px;
            cursor: pointer;
            border-radius: 4px;
        }
        button:disabled {
            background-color: #cccccc;
            cursor: not-allowed;
        }
       /* ===== 全局设置 ===== */
:root {
    --primary-color: #4CAF50;
    --secondary-color: #5bc0de;
    --text-color: #333;
    --light-bg: #f8f9fa;
}

/* ===== 头部区域 ===== */
.practice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 10px;
}

.practice-header h2 {
    font-size: 2.8rem;
    color: var(--text-color);
    margin: 0;
}

.accuracy-badge {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 20px;
    border-radius: 30px;
    font-size: 2.2rem;
    font-weight: bold;
    text-align: center;
    min-width: 180px;
}

.accuracy-detail {
    font-size: 1.4rem;
    opacity: 0.9;
    margin-top: 5px;
}

/* ===== 问题容器 ===== */
.question-container {
    position: relative;
    min-height: 400px;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 20px;
    background-color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* ===== 四角信息 ===== */
.corner-info {
    position: absolute;
    padding: 6px 12px;
    background-color: var(--light-bg);
    border-radius: 6px;
    font-size: 1.2rem; /* 最小的字号 */
    color: #666;
    z-index: 1;
}

.top-left { top: 15px; left: 15px; }
.top-right { top: 15px; right: 15px; }
.bottom-left { bottom: 15px; left: 15px; }
.bottom-right { bottom: 15px; right: 15px; }

/* ===== 核心内容区 ===== */
.question-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px;
}

/* 题目文字 - 最大 */
.question {
    font-size: 3.8rem; /* 约60px */
    margin: 30px 0;
    line-height: 1.3;
    text-align: left;
    color: var(--text-color);
    font-weight: 500;
    padding: 0 10px;
}

/* 选项区域 - 次级大小 */
.options {
    margin: 40px 0;
    text-align: center;
}

.options label {
    display: inline-block;
    margin: 0 25px;
    font-size: 2.2rem; /* 约35px */
    cursor: pointer;
    vertical-align: middle;
}

/* 单选按钮样式 */
.options input[type="radio"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border: 3px solid var(--primary-color);
    border-radius: 50%;
    margin-right: 12px;
    position: relative;
    top: -2px;
    cursor: pointer;
    transition: all 0.2s;
}

.options input[type="radio"]:checked {
    background-color: var(--primary-color);
    box-shadow: 0 0 0 3px white, 0 0 0 6px var(--primary-color);
}

.options input[type="radio"]:hover {
    transform: scale(1.1);
}

/* 下一题按钮 - 次级大小 */
#nextQuestion {
    font-size: 1.8rem;
    padding: 12px 30px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 20px;
}

#nextQuestion:hover {
    background-color: #45a049;
    transform: translateY(-2px);
}

#nextQuestion:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
}

/* 反馈和解析 - 次级大小 */
.feedback {
    margin: 30px 0;
    font-size: 2rem;
    padding: 15px;
    border-radius: 6px;
}

.feedback.correct {
    background-color: #dff0d8;
    color: #3c763d;
}

.feedback.incorrect {
    background-color: #f2dede;
    color: #a94442;
}

.explanation {
    font-size: 1.8rem;
    margin: 20px 0;
    padding: 20px;
    background-color: var(--light-bg);
    border-left: 5px solid var(--secondary-color);
    border-radius: 0 6px 6px 0;
    text-align: left;
}

/* ===== 字号控制 ===== */
.font-size-controls {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background-color: var(--light-bg);
    border-radius: 8px;
}

.font-size-controls button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    margin: 0 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.6rem;
}

#fontSizeDisplay {
    display: inline-block;
    width: 60px;
    font-size: 1.6rem;
    font-weight: bold;
}

.answer-controls {
    display: flex;
    align-items: center;
    gap: 15px; /* 控制元素之间的间距 */
    margin-top: 15px;
}

.accuracy-badge, .accuracy-detail, .options {
    display: flex;
    align-items: center;
}

.options label {
    margin-right: 15px; /* 单选按钮之间的间距 */
    display: flex;
    align-items: center;
}

.options label:last-child {
    margin-right: 0;
}

#nextQuestion {
    margin-left: auto; /* 让按钮靠右 */
}

.controls-container {
    display: flex;
    justify-content: space-between; /* 让两部分分别靠左右 */
    align-items: center;
    padding: 10px;
    background-color: #f5f5f5;
    border-radius: 5px;
    margin-bottom: 15px;
}

.font-size-controls, .fullscreen-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.font-size-controls button, 
.fullscreen-controls button {
    padding: 5px 10px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.font-size-controls button:hover, 
.fullscreen-controls button:hover {
    background-color: #45a049;
}

#fontSizeDisplay {
    min-width: 40px;
    text-align: center;
}

// CSS样式
.fullscreen-mode {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    background: white !important;
    overflow: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

.chapter-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 每行3列 */
    gap: 12px; /* 章节之间的间距 */
    padding: 10px;
}

.chapter-item {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
}

.chapter-item:hover {
    background: #e9e9e9;
}

.chapter-item label {
    display: block;
    cursor: pointer;
}


/* 章节区标题行布局 */
.section-header {
    display: flex;
    justify-content: space-between; /* 标题靠左，按钮靠右 */
    align-items: center;           /* 垂直居中 */
    margin-bottom: 15px;           /* 和下方内容保持间距 */
}

/* 按钮样式调整（可选） */
#startPractice {
    padding: 6px 12px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#startPractice:hover {
    background-color: #45a049;
}

#startPractice:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* 错题本区样式 */
#wrong {
    font-size: 14px; /* 设置基础字体大小 */
}

.wrong-questions {
    font-size: 1em; /* 继承父级字体大小 */
}

.wrong-question {
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f9f9f9;
    border-left: 3px solid #ff6b6b;
}

.wrong-question .question {
    font-size: 1.1em; /* 比正文稍大一点 */
    color: #333;
    margin-bottom: 8px;
}

.wrong-question .correct-answer {
    color: #4CAF50;
    font-weight: bold;
    margin-bottom: 8px;
}

.wrong-question .explanation {
    font-size: 1em;
    color: #666;
    line-height: 1.5;
}

.wrong-question .source {
    font-size: 0.9em;
    color: #999;
    margin-top: 5px;
}

.clear-btn {
    background-color: #ff6b6b;
    color: white;
    padding: 6px 12px;
    margin-top: 10px;
}



    </style>
</head>
<body>
    <div class="container">
        <h1>易莲生梦-刷题帮-桌面版</h1>
        
        <div class="nav">
            <a href="#" class="nav-link active" data-section="upload">加载题库</a>
            <a href="#" class="nav-link" data-section="chapters">选择章节</a>
            <a href="#" class="nav-link" data-section="practice">刷题练习</a>
            <a href="#" class="nav-link" data-section="wrong">错题本</a>
        </div>
        
        <!-- 上传文件区 -->
        <div id="upload" class="section active">
<h2>您可以：从腾讯云加载最新云题库</h2>
    <p>请选择预设题库：</p>
    <select id="presetCsvSelect">
        <option value="">-- 请选择 --</option>
        <option value="https://his-1351542833.cos.ap-guangzhou.myqcloud.com/questions.csv">高中生物</option>
        <option value="https://his-1351542833.cos.ap-guangzhou.myqcloud.com/xxyuwen.csv">小学语文</option>
        <!-- 可以添加更多预设选项 -->
    </select>
    <button id="loadPresetUrl">加载网络题库</button>
    <div id="presetUrlStatus"></div>



    <h2>没有网络时：上传本地题库文件</h2>
    <p>请上传CSV格式的题库文件：</p>
    <input type="file" id="fileInput" accept=".csv">
    <button id="loadFile">加载本地题库</button>
    <div id="fileStatus"></div>
    
    
    
</div>
        
        <!-- 选章节区 -->
        <div id="chapters" class="section">
    <div class="section-header">
        <h2>选择刷题章节</h2>
        <button id="startPractice" disabled>开始刷题</button>
    </div>
    <div id="chapterList" class="chapter-list">
        <p>请先加载题库文件</p>
    </div>
</div>
        
        <!-- 修正后的答题区 -->
<div id="practice" class="section">
    <div class="practice-header">
        
        
      
        
    </div>
    
    <div class="question-container">
        <!-- 四角信息 -->
        <div class="corner-info top-left" id="practiceInfo"></div>
        <div class="corner-info top-right"><span id="progressText">0/0</span></div>
        <div class="corner-info bottom-left" id="sourceInfo"></div> <!-- 修改id为sourceInfo -->
        <div class="corner-info bottom-right" id="difficultyInfo"></div> <!-- 修改id为difficultyInfo -->
        
        <!-- 核心内容 -->
        <div class="question-content">
            <div id="question" class="question"></div>

            <div class="answer-controls">
    <div class="accuracy-badge">正确率: <span id="accuracy">0%</span></div>
    <div class="accuracy-detail"></div>
    <div class="options">
        <label><input type="radio" name="answer" value="correct"> 正确</label>
        <label><input type="radio" name="answer" value="incorrect"> 错误</label>
    </div>
    <button id="nextQuestion" disabled>下一题</button>
</div>
            
            <div id="feedback" class="feedback"></div>
            
            
        </div>

    </div>
    
    <!-- 字号控制 -->
    <div class="font-size-controls">
        <button id="decreaseFont">A-</button>
        <span id="fontSizeDisplay">24px</span>
        <button id="increaseFont">A+</button>
    </div>

</div>
        
        <!-- 错题本区 -->
        <div id="wrong" class="section">
            <h2>错题本</h2>
<button id="redoWrong" class="clear-btn" disabled>重做错题</button>
            
            <div id="wrongList" class="wrong-questions">
                <p>暂无错题记录</p>
            </div>
            <button id="clearWrong" class="clear-btn" disabled>清空错题</button>
        </div>
    </div>

    <script>
        // 全局变量
        let questions = [];
        let currentQuestionIndex = -1;
        let selectedChapters = [];
        let filteredQuestions = [];
        let answeredQuestions = [];
        let wrongQuestions = JSON.parse(localStorage.getItem('wrongQuestions')) || [];
        let stats = {
            correct: 0,
            total: 0
        };
        
        // DOM元素
        const sections = document.querySelectorAll('.section');
        const navLinks = document.querySelectorAll('.nav-link');
        const fileInput = document.getElementById('fileInput');
        const loadFileBtn = document.getElementById('loadFile');
        const fileStatus = document.getElementById('fileStatus');
        const chapterList = document.getElementById('chapterList');
        const startPracticeBtn = document.getElementById('startPractice');
        const practiceInfo = document.getElementById('practiceInfo');
        const progressText = document.getElementById('progressText');
        const difficultyElement = document.getElementById('difficulty');
        const questionElement = document.getElementById('question');
        const sourceElement = document.getElementById('source');
        const answerRadios = document.querySelectorAll('input[name="answer"]');
        const feedbackElement = document.getElementById('feedback');
        const explanationElement = document.getElementById('explanation');
        const nextQuestionBtn = document.getElementById('nextQuestion');
        const accuracyElement = document.getElementById('accuracy');
        const correctCountElement = document.getElementById('correctCount');
        const totalCountElement = document.getElementById('totalCount');
        const wrongList = document.getElementById('wrongList');
        const redoWrongBtn = document.getElementById('redoWrong');
        const clearWrongBtn = document.getElementById('clearWrong');
        
        // 导航切换
        navLinks.forEach(link => {
            link.addEventListener('click', (e) => {
                e.preventDefault();
                const sectionId = link.getAttribute('data-section');
                
                // 更新导航样式
                navLinks.forEach(l => l.classList.remove('active'));
                link.classList.add('active');
                
                // 显示对应区域
                sections.forEach(section => section.classList.remove('active'));
                document.getElementById(sectionId).classList.add('active');
                
                // 如果是错题本，更新显示
                if (sectionId === 'wrong') {
                    updateWrongList();
                }
            });
        });
        
        // 修改加载CSV文件的部分（替换原来的loadFileBtn事件监听器）
loadFileBtn.addEventListener('click', () => {
    const file = fileInput.files[0];
    if (!file) {
        fileStatus.textContent = '请选择文件';
        fileStatus.style.color = 'red';
        return;
    }
    
    const reader = new FileReader();
    reader.onload = function(e) {
        try {
            const csvData = e.target.result;
            questions = parseCSV(csvData);
            
            if (questions.length === 0) {
                fileStatus.textContent = '题库中没有问题';
                fileStatus.style.color = 'red';
                return;
            }
            
            fileStatus.textContent = `成功加载 ${questions.length} 道题目`;
            fileStatus.style.color = 'green';
            
            // 更新章节列表
            updateChapterList();
            
            // 启用开始练习按钮
            startPracticeBtn.disabled = false;
            
            // 弹出提示框并切换到选章节区
            alert(`成功加载 ${questions.length} 道题目`);
            document.querySelector('.nav-link[data-section="chapters"]').click();
            
        } catch (error) {
            fileStatus.textContent = '解析CSV文件出错: ' + error.message;
            fileStatus.style.color = 'red';
        }
    };
    reader.readAsText(file, 'UTF-8');
});
        
        // 解析CSV文件
        function parseCSV(csvData) {
            const lines = csvData.split('\n');
            if (lines.length < 2) return [];
            
            // 获取标题行
            const headers = lines[0].trim().split(',');
            
            // 解析数据行
            const result = [];
            for (let i = 1; i < lines.length; i++) {
                const line = lines[i].trim();
                if (!line) continue;
                
                const values = line.split(',');
                const item = {};
                
                for (let j = 0; j < headers.length && j < values.length; j++) {
                    item[headers[j]] = values[j];
                }
                
                result.push(item);
            }
            
            return result;
        }
        
        // 更新章节列表
        function updateChapterList() {
            // 收集所有章节
            const chaptersMap = {};
            questions.forEach(q => {
                if (q.zhangjie) {
                    if (!chaptersMap[q.zhangjie]) {
                        chaptersMap[q.zhangjie] = 0;
                    }
                    chaptersMap[q.zhangjie]++;
                }
            });
            
            // 转换为数组并保持原始顺序
            const chapters = [];
            questions.forEach(q => {
                if (q.zhangjie && !chapters.some(c => c.name === q.zhangjie)) {
                    chapters.push({
                        name: q.zhangjie,
                        count: chaptersMap[q.zhangjie]
                    });
                }
            });


            
            // 渲染章节列表
            if (chapters.length === 0) {
                chapterList.innerHTML = '<p>题库中没有章节信息</p>';
                return;
            }
            
            chapterList.innerHTML = '';
            chapters.forEach(chapter => {
                const div = document.createElement('div');
                div.className = 'chapter-item';
                div.innerHTML = `
                    <label>
                        <input type="checkbox" value="${chapter.name}">
                        ${chapter.name} (${chapter.count}题)
                    </label>
                `;
                chapterList.appendChild(div);
            });
        }
        
        // 开始练习
        startPracticeBtn.addEventListener('click', () => {
            // 获取选中的章节
            selectedChapters = [];
            const checkboxes = chapterList.querySelectorAll('input[type="checkbox"]:checked');
            checkboxes.forEach(cb => {
                selectedChapters.push(cb.value);
            });
            
            if (selectedChapters.length === 0) {
                alert('请至少选择一个章节');
                return;
            }
            
            // 过滤问题
            filteredQuestions = questions.filter(q => selectedChapters.includes(q.zhangjie));
            
            if (filteredQuestions.length === 0) {
                alert('所选章节没有问题');
                return;
            }
            
            // 重置练习状态
            answeredQuestions = [];
            stats = {
                correct: 0,
                total: 0
            };
            
            // 显示练习信息
            practiceInfo.textContent = `当前练习: ${selectedChapters.join(', ')} (共 ${filteredQuestions.length} 题)`;
            
            // 导航到练习区
            document.querySelector('.nav-link[data-section="practice"]').click();
            
            // 开始第一题
            nextQuestion();
        });


// 加载预设网络CSV文件
document.getElementById('loadPresetUrl').addEventListener('click', async function() {
    const csvUrl = document.getElementById('presetCsvSelect').value;
    const urlStatus = document.getElementById('presetUrlStatus');
    
    if (!csvUrl) {
        urlStatus.textContent = '请选择要加载的题库';
        urlStatus.style.color = 'red';
        return;
    }
    
    try {
        urlStatus.textContent = '正在从腾讯云加载...';
        urlStatus.style.color = 'black';
        
        // 直接使用fetch API获取CSV文件
        const response = await fetch(csvUrl);
        
        if (!response.ok) throw new Error(`加载失败，状态码: ${response.status}`);
        
        const csvData = await response.text();
        questions = parseCSV(csvData);
        
        if (questions.length === 0) {
            urlStatus.textContent = '题库中没有问题';
            urlStatus.style.color = 'red';
            return;
        }
        
        urlStatus.textContent = `成功加载 ${questions.length} 道题目`;
        urlStatus.style.color = 'green';
        updateChapterList();
        startPracticeBtn.disabled = false;
        alert(`成功从腾讯云加载 ${questions.length} 道题目`);
        document.querySelector('.nav-link[data-section="chapters"]').click();
        
    } catch (error) {
        urlStatus.textContent = '加载失败: ' + error.message;
        urlStatus.style.color = 'red';
        console.error('从腾讯云加载CSV失败:', error);
    }
});





        
        // 下一题
        nextQuestionBtn.addEventListener('click', () => {
            // 检查是否所有题目都已回答
            if (answeredQuestions.length === filteredQuestions.length) {
                // 显示结果
                alert(`练习完成!\n正确率: ${Math.round((stats.correct / stats.total) * 100)}%`);
                nextQuestionBtn.textContent = '下一题';
                nextQuestionBtn.disabled = true;
                return;
            }
            
            nextQuestion();
        });
        
        // 获取下一题
        function nextQuestion() {
    // 重置UI
    answerRadios.forEach(radio => {
        radio.checked = false;
        radio.disabled = false;
    });
    feedbackElement.style.display = 'none';
    nextQuestionBtn.disabled = true;
    
    // 从未回答的问题中随机选择
    let availableQuestions = filteredQuestions.filter((_, index) => !answeredQuestions.includes(index));
    
    if (availableQuestions.length === 0) {
        // 所有问题都已回答，重新开始
        availableQuestions = filteredQuestions;
        answeredQuestions = [];
    }
    
    currentQuestionIndex = filteredQuestions.indexOf(
        availableQuestions[Math.floor(Math.random() * availableQuestions.length)]
    );
    
    const question = filteredQuestions[currentQuestionIndex];
    
    // 随机选择显示正确还是错误描述
    const showCorrect = Math.random() < 0.5;
    const displayText = showCorrect ? question.duide : question.cuode;
    const correctAnswer = showCorrect ? 'correct' : 'incorrect';
    
    // 更新UI
    questionElement.textContent = displayText;
    document.getElementById('difficultyInfo').innerHTML = '难度: ' + '★'.repeat(parseInt(question.nandu)) + '☆'.repeat(5 - parseInt(question.nandu));
    document.getElementById('sourceInfo').textContent = '题源: ' + (question.yuncuoci || '未知');
    progressText.textContent = `${answeredQuestions.length + 1}/${filteredQuestions.length}`;
    
    // 存储正确答案
    questionElement.dataset.correctAnswer = correctAnswer;
    questionElement.dataset.explanation = question.jiexi;
    
    // 更新统计
    updateStats();
}
        
        // 回答选择
        answerRadios.forEach(radio => {
            radio.addEventListener('change', () => {
                if (radio.checked) {
                    checkAnswer(radio.value);
                }
            });
        });
        
        // 检查答案
        function checkAnswer(selectedAnswer) {
    const correctAnswer = questionElement.dataset.correctAnswer;
    const isCorrect = selectedAnswer === correctAnswer;
    const explanation = questionElement.dataset.explanation;
    
    // 禁用选择
    answerRadios.forEach(radio => radio.disabled = true);
    
    // 更新反馈区域
    feedbackElement.style.display = 'block';
    feedbackElement.className = 'feedback ' + (isCorrect ? 'correct' : 'incorrect');
    
    if (isCorrect) {
        feedbackElement.innerHTML = '恭喜你答对了！';
    } else {
        feedbackElement.innerHTML = `
            <div>可惜答错了，快看解析：</div>
            <div class="explanation">${explanation}</div>
        `;
    }
    
    // 启用下一题按钮
    nextQuestionBtn.disabled = false;
    
    // 记录已回答
    if (!answeredQuestions.includes(currentQuestionIndex)) {
        answeredQuestions.push(currentQuestionIndex);
    }
    
    // 更新统计
    stats.total++;
    if (isCorrect) stats.correct++;
    updateStats();
    
    // 添加到错题本
    if (!isCorrect) {
        addToWrongList(filteredQuestions[currentQuestionIndex], correctAnswer === 'correct' ? '正确' : '错误');
    }
}
        
        // 更新统计信息
        function updateStats() {
            const accuracy = stats.total > 0 ? Math.round((stats.correct / stats.total) * 100) : 0;
            accuracyElement.textContent = accuracy + '%';
            correctCountElement.textContent = stats.correct;
            totalCountElement.textContent = stats.total;
        }
        
        // 添加到错题本
        function addToWrongList(question, correctAnswer) {
            // 检查是否已存在
            const exists = wrongQuestions.some(q => 
                q.duide === question.duide && 
                q.cuode === question.cuode && 
                q.zhangjie === question.zhangjie
            );
            
            if (!exists) {
                wrongQuestions.push({
                    ...question,
                    correctAnswer: correctAnswer,
                    timestamp: new Date().toISOString()
                });
                
                // 保存到本地存储
                localStorage.setItem('wrongQuestions', JSON.stringify(wrongQuestions));
                
                // 更新错题本按钮状态
                redoWrongBtn.disabled = false;
                clearWrongBtn.disabled = false;
            }
        }
        
        // 更新错题本列表
        function updateWrongList() {
            if (wrongQuestions.length === 0) {
                wrongList.innerHTML = '<p>暂无错题记录</p>';
                redoWrongBtn.disabled = true;
                clearWrongBtn.disabled = true;
                return;
            }
            
            wrongList.innerHTML = '';
            wrongQuestions.forEach((q, index) => {
                const div = document.createElement('div');
                div.className = 'wrong-question';
                div.innerHTML = `
                    <div class="question">${q.correctAnswer === '正确' ? q.duide : q.cuode}</div>
                    <div class="correct-answer">正确答案: ${q.correctAnswer}</div>
                    <div class="explanation">${q.jiexi}</div>
                    <div class="source">章节: ${q.zhangjie} | 难度: ${'★'.repeat(parseInt(q.nandu))} | 题源: ${q.yuncuoci || '未知'}</div>
                    <button class="clear-btn" data-index="${index}">删除</button>
                `;
                wrongList.appendChild(div);
            });
            
            // 添加删除按钮事件
            wrongList.querySelectorAll('.clear-btn').forEach(btn => {
                btn.addEventListener('click', (e) => {
                    const index = parseInt(e.target.getAttribute('data-index'));
                    wrongQuestions.splice(index, 1);
                    localStorage.setItem('wrongQuestions', JSON.stringify(wrongQuestions));
                    updateWrongList();
                });
            });
            
            redoWrongBtn.disabled = false;
            clearWrongBtn.disabled = false;
        }
        
        // 重做错题
        redoWrongBtn.addEventListener('click', () => {
            if (wrongQuestions.length === 0) {
                alert('没有错题可以重做');
                return;
            }
            
            // 创建错题练习集
            filteredQuestions = wrongQuestions.map(q => ({
                ...q,
                // 恢复原始格式
                correctAnswer: undefined,
                timestamp: undefined
            }));
            
            // 重置练习状态
            answeredQuestions = [];
            stats = {
                correct: 0,
                total: 0
            };
            
            // 显示练习信息
            practiceInfo.textContent = `当前练习: 错题重做 (共 ${filteredQuestions.length} 题)`;
            
            // 导航到练习区
            document.querySelector('.nav-link[data-section="practice"]').click();
            
            // 开始第一题
            nextQuestion();
        });
        
        // 清空错题
        clearWrongBtn.addEventListener('click', () => {
            if (confirm('确定要清空所有错题记录吗？')) {
                wrongQuestions = [];
                localStorage.removeItem('wrongQuestions');
                updateWrongList();
            }
        });
        
        // 初始化错题本状态
        if (wrongQuestions.length > 0) {
            redoWrongBtn.disabled = false;
            clearWrongBtn.disabled = false;
        }

// 字号控制功能
let currentFontSize = 24; // 默认字号24px

document.getElementById('increaseFont').addEventListener('click', () => {
    if (currentFontSize < 66) {
        currentFontSize += 1;
        updateFontSize();
    }
});

document.getElementById('decreaseFont').addEventListener('click', () => {
    if (currentFontSize > 20) {
        currentFontSize -= 1;
        updateFontSize();
    }
});

function updateFontSize() {
    // 更新显示
    document.getElementById('fontSizeDisplay').textContent = `${currentFontSize}px`;
    
    // 应用字号到答题区
    const practiceSection = document.getElementById('practice');
    practiceSection.style.fontSize = `${currentFontSize}px`;
    
    // 单独调整题目字号（比正文大2px）
    document.querySelectorAll('.question').forEach(el => {
        el.style.fontSize = `${currentFontSize + 2}px`;
    });
    
    // 保存到本地存储
    localStorage.setItem('fontSize', currentFontSize);
}

// 初始化时读取保存的字号
const savedFontSize = localStorage.getItem('fontSize');
if (savedFontSize) {
    currentFontSize = parseInt(savedFontSize);
    updateFontSize();
}



    </script>
</body>
</html>